@extends('Admin.layout.layout')
@section('content')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>广告位置管理</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <form action="/foradmin/advertisingposition" method="GET">
                                <div class="col-sm-12">
                                    <a class="btn-sm btn-success" href="/foradmin/advertisingposition/create">新增</a>
                                </div>
                            </form>
                        </div>
                        <table class="table table-striped table-bordered table-hover dataTable" id="editable">
                            <thead>
                            <tr>
                                <th width="15">
                                    ID
                                </th>
                                <th>页面排序</th>
                                <th>位置名称</th>
                                <th>展示</th>
                                <th>创建时间</th>
                                <th class="center">操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            @if(!empty($list))
                                @foreach($list as $value)
                                    <tr class="gradeX">
                                        <td>{{array_get($value, 'id')}}</td>
                                        <td><span> {{array_get($value, 'sort')}}</span></td>
                                        <td><span> {{array_get($value, 'title')}}</span></td>
                                        <?php $STATUS = ['1' => '审核', '0' => '未审核']; ?>
                                        {{--<td><span> </span></td>--}}
                                        <td>
                                            <p class= "user">{{array_get($STATUS, $value['audit'] )}}：
                                                <img class="status_show setShow" title="点击禁用" @if(array_get($value, 'audit') == 0) style="display: none;" @endif src="{{asset('img/start.png')}}"  data-show='0' data-id='{{array_get($value, 'id')}}' alt="">

                                                <img class="status_hide setShow" title="点击启用"@if(array_get($value, 'audit') == 1) style="display: none;" @endif src="{{asset('img/close.png')}}"  data-show='1' data-id='{{array_get($value, 'id')}}'>

                                            </p>
                                        </td>
                                        <td>{{array_get($value, 'created_at')}}</td>
                                        <td class="center">
                                            <a class="btn btn-xs btn-warning" href="/foradmin/advertisingposition/{{$value['id']}}/edit">编辑</a>
                                            <button class="btn btn-xs btn-danger"
                                                    data-url="{{URL::to('foradmin/advertisingposition/'.$value['id'])}}"
                                                    data-toggle="modal"
                                                    data-target="#delete-modal"
                                            >
                                                删除
                                            </button>
                                        </td>
                                    </tr>
                                @endforeach
                            @else
                                <tr class="no-records-found center"><td colspan="8">没有广告位置</td></tr>
                            @endif
                            </tbody>
                        </table>
                        <div class="row">
                            @include('Admin.common.paginate', ['page' => $page])
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function () {
            $(document).on("click",".setShow",function(){
                var audit = $(this).attr('data-show');
                var id =  $(this).attr('data-id');
                $.ajax({
                    url : '/foradmin/advertisingposition/setShow/'+id,
                    type : 'post',
                    dataType : "json",
                    data : {audit:audit},
                    success : function(data) {
                        if (0 == data.code) {
                            layer.alert('设置成功！', {
                                icon: 1
                            }, function () {
                                location.href = "/foradmin/advertisingposition";
                            });
                        } else {
                            layer.alert(data.message, {
                                icon: 2
                            });
                        }
                    }
                });

            });
        });
    </script>
@endsection

@section("after.js")
    @include('Admin.components.modal.delete',['title'=>'操作提示','content'=>'你确定要删除这个广告位置吗?'])
@endsection